/**
 * Copyright (C), 2015, 上海赛可电子商务有限公司
 * Author:   张卫明
 * Date:     2015-5-6
 * lever:    page
 * Description: 提交订单页js
 */

;(function($,window) {
	
	var $agentCheck = $('#agentCheck'),$submitOrder = $('#submitOrder');
	
	orderPage = {
			
		init:function(){
			
			//是否同意用户协议
			this.agentCheck();
			
			//提交表单
			this.formOrder();
			
			//联系客服
			this.im();
		},
		agentCheck:function(){
			var _this=this;
			
			this._agentCheck();
			
			$agentCheck.on('click',function(){
				_this._agentCheck();
			});
			
		},
		_agentCheck:function(_this){
			if($agentCheck.attr("checked") == 'checked'){
				if($submitOrder.hasClass('btn-disabled')){
					$submitOrder.removeClass('btn-disabled');
				}
			} else {
				if(!$submitOrder.hasClass('btn-disabled')){
					$submitOrder.addClass('btn-disabled');
				}
			}
		},
		formOrder:function(){
			
			$submitOrder.on('click',function(){
				
				if($agentCheck.attr("checked") != 'checked'){
					return false;
				}
				document.getElementById("formOrder").submit();
				
			});
			
		},
		im:function(){
			var csimUrl = 'http://kf1.chexiang.com/new/client.php?unique_id=&unique_name=&arg=admin&style=2&l=zh-cn&lytype=0&charset=gbk&referer=http%3A%2F%2Fwww.chexiang.com%2F&isvip=bcf14bbb85a346c2fb52e8cea8822cce&identifier=&keyword=&tfrom=1&tpl=crystal_blue';
		
			$('.help-service').on('click',function(){
				window.open(csimUrl, "车享客服", "height=573, width=803, top=80, left=300,toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=n o, status=no");
			});
		}
		
	};
	
	orderPage.init();
	
})(jQuery,window);

